"""
---------------------------------------------------------------------
- File: service.py
- Date: 2025/8/8
- Author: yangzhide
- Email: xxzjyzd@126.com
- Description:
---------------------------------------------------------------------
"""

from datetime import datetime, timedelta, timezone
from jwt.exceptions import InvalidTokenError
from passlib.context import CryptContext
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from app.core.config import app_settings

pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")

tokenUrl = f"/api/{app_settings.APP_VERSION}/endpoints/security/token"

oauth2_scheme = OAuth2PasswordBearer(tokenUrl)


async def get_password_hash(password):
    """密码哈希"""
    return pwd_context.hash(password)


async def verify_password(plain_password, hashed_password):
    """验证密码"""
    return pwd_context.verify(plain_password, hashed_password)
